# 装饰器

# def outer(sleep):
#     def inner():
#         print("前")
#         sleep()
#         print("后")
#     return inner
#
# def sleep():
#     import random
#     import time
#     print("睡觉中")
#     time.sleep(random.randint(1,5))
#
# fn = outer(sleep)
# fn()

# 语法糖写法
def outer(sleep):
    def inner():
        print("前")
        sleep()
        print("后")
    return inner


@outer
def sleep():
    import random
    import time
    print("睡觉中")
    time.sleep(random.randint(1, 5))

sleep()